<include file="Public/_meta" />
<title>中介管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 中介管理 <span class="c-gray en">&gt;</span> 中介列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
    	<form action="{:U('Media/search')}" method="post">
    	<input type="text" class="input-text" style="width:250px" placeholder="输入中介名称" value="{$searname}" name="agentname">
		<button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜中介</button>
		</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
		  <a href="javascript:;" onclick="agent_add('添加中介','{:U('Media/mediationadd')}','500','300')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加中介</a>
		</span>
		<span class="r">共有数据：<strong>{$AgentNum}</strong> 条</span>
	</div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th width="80">ID</th>
				<th width="100">中介名称</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			<volist name="agents" id="ag">
			<tr class="text-c">
				<td><input type="checkbox" value="{$ag.agent_id}" name="id"></td>
				<td>{$i}</td>
				<td>{$ag.company_name}</td>
				<td class="td-manage">
					<a title="编辑" href="javascript:;" onclick="agent_edit('编辑','{:U('Media/mediationalert',array('id'=>$ag['agent_id']))}','500','300')" class="ml-5" style="text-decoration:none">编辑</a>
					<a title="删除" href="javascript:;" onclick="agent_del(this,'{$ag.agent_id}')" class="ml-5" style="text-decoration:none">删除</a></td>
			</tr>
		</volist>
		</tbody>
	</table>
	</div>
	
	<div class="manu">
        {$page}
    </div>
</div>



﻿<include file="Public/_footer" />
<script type="text/javascript">
$(function(){
	$('.table-sort').dataTable({
		"aaSorting": [[ 1, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[0,8,9]}// 制定列不参与排序
		]
	});
	$('.table-sort tbody').on( 'click', 'tr', function () {
		if ( $(this).hasClass('selected') ) {
			$(this).removeClass('selected');
		}
		else {
			table.$('tr.selected').removeClass('selected');
			$(this).addClass('selected');
		}
	});
});
/*中介-添加*/
function agent_add(title,url,w,h){
	layer_show(title,url,w,h);
}


/*中介-编辑*/
function agent_edit(title,url,w,h){
	layer_show(title,url,w,h);
}

/*中介-删除*/
function agent_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			url:'{:U("Media/delCheck")}',
			type:'post',
			data:{agentid:id},
			dataType:'json',
			success:function(data){
				if(data.ResultCode == '200'){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:1,time:1000});
				}
				else if(data.ResultCode == '500'){
						layer.msg(data.ResultMessage);
				}
			}
		})

	});
}

function datadel(){
	var chk_value =[];
   $('input[name="id"]:checked').each(function(){
   chk_value.push($(this).val());
  });

  if(chk_value.length==0){
    layer.msg('您还没有选择要删除的数据');
  }
  else{
    $.ajax({
           type:"post",
           url:"{:U('Media/delDatas')}",
           data:{id:chk_value},
           dataType:'json',
           success:function(msg){
               if(msg.ResultCode=='200'){
                 layer.msg(msg.ResultMessage,{time:1000},  function(){
                   window.location.reload();
                 });
               }
               else{layer.msg(msg.ResultMessage)}
           }
       });
  }
}
</script>
</body>
</html>
